<template>
	<view class="box">
		<web-view v-if="islogoin" :src="url"></web-view>
	</view>
</template>
<script>
	import myHearder from '../../components/header/header.vue'
	import {gameUserCode,siteConfig} from "@/api/api.js"
	export default {
		components: {
			myHearder
		},
		data() {
			return {
				url:'',
				islogoin:false,
				mobileInfo:'',
			}
		},
		onLoad(e) {
			let _this = this
			// uni.getSystemInfo({
			//     success: function (ev) {
			        // console.log(ev.model);
			        // console.log(ev.pixelRatio);
			        // console.log(ev.windowWidth);
			        // console.log(ev.windowHeight);
			        // console.log(ev.language);
			        // console.log(ev.version);
			        // console.log(ev.platform);
				// 	_this.mobileInfo=ev.brand||''
			 //    },
				// });
			webview.clearCache(true)
			console.log(webview)
		},
		onShow() {
			console.log('url：' + this.url);
			this.getUserInfo();
		},
		methods: {
			getUserInfo(){
				let _this= this
				let info = {}
				gameUserCode().then((res) => {
					if(res.msg){
						// uni.setStorageSync('userInfo',res.data)
						// let userInfo = uni.getStorageSync('userInfo');
						// console.log(_this.mobileInfo)
						// if( _this.mobileInfo!='' && _this.mobileInfo.indexOf('huawei')!=-1||_this.mobileInfo.indexOf('HUAWEI')!=-1){
						// 	console.log("huawei,farurl:",_this.$api.farHttp)
							this.url = 'http://game.cqmv.com/farmer/index.html?token=' + res.msg;	
						// }else{
						// 	console.log("other")
							// this.url = '/hybrid/html/index.html?token=' + res.msg;
						// }
						this.islogoin=true;
					}else{
						uni.navigateTo({
							url: '../users/login/index'
						})
					}
				})
			},
			goto(url) {
				if (url == '') {
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.navigateTo({
						url: url
					})
				}
			},
		},
	}
</script>

<style scoped>
	@import url("/static/css/public.css");
	
	page {
		width: 100%;
		height: 100%;
	}
	
	.box{
		/* padding-bottom: 40rpx; */
		width: 100%;
		min-height: 100%;
		background-color: #F5F5F5;
	}

.goods-box{
		width: 48%;
		margin-bottom: 20rpx;
	}
</style>
